#ifndef __CUST_SPI_H__
#define __CUST_SPI_H__
enum
{
	SPI_ID1,
	SPI_ID2,
	SPI_MAX,
	SPI_XFER_DONE_IRQ = 0,
	SPI_XFER_ERROR_IRQ,
	SPI_MODE_0 = 0,
	SPI_MODE_1,
	SPI_MODE_2,
	SPI_MODE_3,
	SPI_IO_SYNC = 0,
	SPI_IO_ASYNC,
	SPI_TXRX_IRQ = 0,
	SPI_TXRX_DMA,
};

typedef struct
{
	MyCBFun_t CB;
	PV_Union uTxBuf;
	PV_Union uRxBuf;
	uint16_t XferLen;
	uint16_t FinishLen;
	GPIO_TypeDef  *NSSPort;
	uint32_t NSSPin;
	uint8_t TxBusy;
	uint8_t Bit;
}SPI_CtrlStruct;

int32_t SPI_TxRxByte(uint8_t SpiID, uint8_t TxByte, uint8_t *RxByte);
int32_t SPI_Xfer(uint8_t SpiID, void *TxSrc, void *RxDst, uint16_t Len, uint8_t IsAsync, uint8_t IsDMAMode);
void SPI_Init(uint8_t SpiID, uint32_t BR, uint8_t IsSlave, uint8_t Mode, MyCBFun_t CB);
void SPI_SetNSSPIN(	uint8_t SpiID, GPIO_TypeDef  *NSSPort, uint32_t NSSPin );
#endif
